<?php defined('SYSPATH') or die('No direct script access.');
/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2020/08/27 15:01
 * Desc: 供应商店铺
 */
class Controller_Pc_Api_V2_Suppliershop extends Controller_Pc_Api_v2_Base
{

    // 数据请求结果
    private $result;

    /**
     * 参数验证对象
     * @var Request_Api_V2_Supplier_Shop
     */
    private $validation;
    /**
     * 服务
     * @var Service_Api_Supplier_Shop
     */
    private $service;

    public function before()
    {
        parent::before();
        $this->result = array(
            'status' => true,
            'msg' => '操作成功',
            'data' => array()
        );
        $this->validation = Request_Api_V2_Factory::create('supplier_shop', $this->request_params);
        $this->service = new Service_Api_Supplier_Shop();

    }
    public function after()
    {
        $this->send_datagrams($this->client_info['id'], $this->result, $this->client_info['secret_key']);
    }
    /**
     * 获取供应商店铺配置
     */
    public function action_get_shop_config(){
        try {
            $this->validation->get_shop_config()->check();
            $data = $this->service->get_shop_config($this->request_params['supplier_id']);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }



    /**
     * @function 获取产品列表
     */
    public function action_get_product_list()
    {
        try {
            $this->validation->get_product_list()->check();
            $data = $this->service->get_product_list($this->request_params);
            $this->result['data'] = $data;
        } catch (Exception $e) {
            $this->result = array('status' => false, 'msg' => $e->getMessage());
        }
    }

}